package com.example.admin.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.admin.R;
import com.example.admin.SQLite.HfBean;
import com.example.admin.SQLite.SqLiteOpenHelper;
import com.example.admin.SQLite.User;
import com.example.admin.bean.PersonalBean;
import com.orhanobut.hawk.Hawk;

import java.util.ArrayList;

public class ForumHfdapter extends BaseQuickAdapter<HfBean, BaseViewHolder> {

    SqLiteOpenHelper dbHelper;

    public ForumHfdapter() {
        super(R.layout.item_hf);
    }

    @Override
    protected void convert(BaseViewHolder helper, HfBean str) {
        ImageView uImg = helper.getView(R.id.ivAvar);
        dbHelper = new SqLiteOpenHelper(mContext);
        if (str.uids.equals("-1")) {
            helper.setText(R.id.tvName, "admin");
            if (Hawk.contains("userAdmin" )) {
                String imgPath = Hawk.get("userAdmin");
                Glide.with(mContext).load(imgPath).into(uImg);
            }
        } else {
            if (Hawk.contains("user" + str.uids)) {
                String imgPath = Hawk.get("user" + str.uids);
                Glide.with(mContext).load(imgPath).into(uImg);
            }
            ArrayList<User> list = dbHelper.findWhereUsers(str.uids);
            helper.setText(R.id.tvName, list.get(0).userName);
        }

        helper.setText(R.id.tvCont, str.cont);
        helper.setText(R.id.tvTime, str.datas);

    }

}